<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

use App\Admin;

class LoginController extends Controller
{
  public function login(){
        

    return view("Admin.index.index");

  }

  public function handle(Request $request){

    $name=$request->input("name");
    $password=$request->input("password");
    // echo ("$name -----------$password");

    $admin = Admin::query()->where('name',$name)->first();
    // dd($admin);
    if(is_null($admin)){
     
      return back()->with('errorns','用户不存在');

      }

      
      if( 
      ! Hash::check($request->input('password'),$admin->password)){
      
          return back()->with('errormsg','密码错误');

       
      }

       // Aurth::guard('admin')->login($admin);

      return view('Admin.Login.index')->with("name",$name);

    
        

    

  }

  public  function index(){


   
   return view("Admin.Login.index")->with("admin",$admin);

  }

}
